perf(client): stop replaying terminal buffers on rollover - #242
Merged
Conversation
Keep terminal attach output as incremental chunks with a 512KiB bound and a cursor so renderers append instead of rewriting the whole buffer on every event. Mobile still materializes a string at the native surface boundary.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Greptile SummaryThe terminal output state now maintains bounded UTF-8 chunk history and synchronizes each renderer safely after rollover, resets, and session changes. Web terminal surfaces pause while hidden and refit when shown, while mobile retains its legacy string boundary. Confidence Score: 5/5Safe to merge. The previously reported rollover issue is fully addressed: readers now reset when their retained-output start offset differs from the current retained boundary, so they cannot append new output onto discarded terminal history. Reviews (2): Last reviewed commit: "fix(client): reset terminal viewport aft..." | Re-trigger Greptile |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Terminal attach state stored one growing string and re-trimmed it on every output event. Clients then replayed the whole buffer into Ghostty or the native surface, which spikes on long sessions. The first incremental implementation also allowed a caught-up viewport to append after retained history rolled over, leaving discarded text visible.
Changes
Keep attach output as incremental UTF-8 chunks with a 512KiB retained bound and a cursor. Renderers append unread data and reset when the attach generation, explicit reset, or retained-output start changes. Each new attach stream gets a new generation so a stale cursor cannot append into the next session.
Mobile still materializes a string at the native surface boundary because the installed native view still takes
initialBuffer.Adapted from pingdotgg#9707. Akeru has no
lifecycleVersionon the buffer state yet; snapshot and restart still reset output throughresetOutput. Ghostty WASM snapshot tests from that PR were left out because this Vitest setup cannot load*.wasm?inline.Verification
vp test run packages/client-runtime/src/state/terminalSession.test.ts apps/web/src/terminal/ghostty/core.test.ts apps/mobile/src/features/terminal/terminalMenu.test.ts apps/web/src/components/ThreadTerminalDrawer.test.ts: 39 passed.git diff --checkpassed.Native mobile terminal was not run on this Linux host.
Implemented and verified by GPT-5.6 Sol in T3 Code via the Codex harness.